home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 2010 Software/Programs / PCGuia_programas.iso / Software / Utils / ASUS PC Probe / setup / data1.cab / App_Executables / PCIInfo / tree.js < prev   
Encoding:
JavaScript  |  2009-11-02  |  11.9 KB  |  477 lines

  1. //**************************************************************** 
  2. // You are free to copy the "Folder-Tree" script as long as you  
  3. // keep this copyright notice: 
  4. // Script found in: http://www.geocities.com/Paris/LeftBank/2178/ 
  5. // Author: Marcelino Alves Martins (martins@hks.com) December '97. 
  6. //**************************************************************** 
  7.  
  8. //Log of changes: 
  9. //       17 Feb 98 - Fix initialization flashing problem with Netscape
  10. //       
  11. //       27 Jan 98 - Root folder starts open; support for USETEXTLINKS; 
  12. //                   make the ftien4 a js file 
  13. //       
  14.  
  15.  
  16. // Definition of class Folder 
  17. // ***************************************************************** 
  18.  
  19. function Folder(folderDescription, hreference) //constructor 
  20.   //constant data 
  21.   this.desc = folderDescription 
  22.   this.hreference = hreference 
  23.   this.id = -1   
  24.   this.navObj = 0  
  25.   this.iconImg = 0  
  26.   this.nodeImg = 0  
  27.   this.isLastNode = 0 
  28.  
  29.   //dynamic data 
  30.   this.isOpen = true 
  31.   this.iconSrc = "ftv2folderopen.gif"   
  32.   this.children = new Array 
  33.   this.nChildren = 0 
  34.  
  35.   //methods 
  36.   this.initialize = initializeFolder 
  37.   this.setState = setStateFolder 
  38.   this.addChild = addChild 
  39.   this.createIndex = createEntryIndex 
  40.   this.hide = hideFolder 
  41.   this.display = display 
  42.   this.renderOb = drawFolder 
  43.   this.totalHeight = totalHeight 
  44.   this.subEntries = folderSubEntries 
  45.   this.outputLink = outputFolderLink 
  46.  
  47. function setStateFolder(isOpen) 
  48.   var subEntries 
  49.   var totalHeight 
  50.   var fIt = 0 
  51.   var i=0 
  52.  
  53.   if (isOpen == this.isOpen) 
  54.     return 
  55.  
  56.   if (browserVersion == 2)  
  57.   { 
  58.     totalHeight = 0 
  59.     for (i=0; i < this.nChildren; i++) 
  60.       totalHeight = totalHeight + this.children[i].navObj.clip.height 
  61.       subEntries = this.subEntries() 
  62.     if (this.isOpen) 
  63.       totalHeight = 0 - totalHeight 
  64.     for (fIt = this.id + subEntries + 1; fIt < nEntries; fIt++) 
  65.       indexOfEntries[fIt].navObj.moveBy(0, totalHeight) 
  66.   }  
  67.   this.isOpen = isOpen 
  68.   propagateChangesInState(this) 
  69.  
  70. function propagateChangesInState(folder) 
  71. {   
  72.   var i=0 
  73.  
  74.   if (folder.isOpen) 
  75.   { 
  76.     if (folder.nodeImg) 
  77.       if (folder.isLastNode) 
  78.         folder.nodeImg.src = "ftv2mlastnode.gif" 
  79.       else 
  80.       folder.nodeImg.src = "ftv2mnode.gif" 
  81.     folder.iconImg.src = "ftv2folderopen.gif" 
  82.     for (i=0; i<folder.nChildren; i++) 
  83.       folder.children[i].display() 
  84.   } 
  85.   else 
  86.   { 
  87.     if (folder.nodeImg) 
  88.       if (folder.isLastNode) 
  89.         folder.nodeImg.src = "ftv2plastnode.gif" 
  90.       else 
  91.       folder.nodeImg.src = "ftv2pnode.gif" 
  92.     folder.iconImg.src = "ftv2folderclosed.gif" 
  93.     for (i=0; i<folder.nChildren; i++) 
  94.       folder.children[i].hide() 
  95.   }  
  96.  
  97. function hideFolder() 
  98.   if (browserVersion == 1) { 
  99.     if (this.navObj.style.display == "none") 
  100.       return 
  101.     this.navObj.style.display = "none" 
  102.   } else { 
  103.     if (this.navObj.visibility == "hiden") 
  104.       return 
  105.     this.navObj.visibility = "hiden" 
  106.   } 
  107.    
  108.   this.setState(0) 
  109.  
  110. function initializeFolder(level, lastNode, leftSide) 
  111. var j=0 
  112. var i=0 
  113. var numberOfFolders 
  114. var numberOfDocs 
  115. var nc 
  116.       
  117.   nc = this.nChildren 
  118.    
  119.   this.createIndex() 
  120.  
  121.   var auxEv = "" 
  122.  
  123.   if (browserVersion > 0) 
  124.     auxEv = "<a href='javascript:clickOnNode("+this.id+")'>" 
  125.   else 
  126.     auxEv = "<a>" 
  127.  
  128.   //if (level>0) 
  129.     if (lastNode) //the last 'brother' in the children array 
  130.     { 
  131.       this.renderOb(leftSide + auxEv + "<img name='nodeIcon" + this.id + "' src='ftv2mlastnode.gif' width=16 height=22 border=0></a>") 
  132.       leftSide = leftSide + "<img src='ftv2blank.gif' width=16 height=22>"  
  133.       this.isLastNode = 1 
  134.     } 
  135.     else 
  136.     { 
  137.       this.renderOb(leftSide + auxEv + "<img name='nodeIcon" + this.id + "' src='ftv2mnode.gif' width=16 height=22 border=0></a>") 
  138.       leftSide = leftSide + "<img src='ftv2vertline.gif' width=16 height=22>" 
  139.       this.isLastNode = 0       
  140.     } 
  141.     
  142.        
  143.   if (nc > 0) 
  144.   { 
  145.     level = level + 1 
  146.     for (i=0 ; i < this.nChildren; i++)  
  147.     { 
  148.       if (i == this.nChildren-1) 
  149.         this.children[i].initialize(level, 1, leftSide) 
  150.       else 
  151.         this.children[i].initialize(level, 0, leftSide) 
  152.     } 
  153.     if(level > 0)
  154.         clickOnNode(this.id) 
  155.   } 
  156.  
  157. function drawFolder(leftSide) 
  158.   if (browserVersion == 2) { 
  159.     if (!doc.yPos) 
  160.       doc.yPos=8 
  161.     doc.write("<layer id='folder" + this.id + "' top=" + doc.yPos + " visibility=hiden>") 
  162.   } 
  163.    
  164.   doc.write("<table ") 
  165.   if (browserVersion == 1) 
  166.     doc.write(" id='folder" + this.id + "' style='position:block;' ") 
  167.   doc.write(" border=0 cellspacing=0 cellpadding=0>") 
  168.   doc.write("<tr><td>") 
  169.   doc.write(leftSide) 
  170.   this.outputLink() 
  171.   doc.write("<img name='folderIcon" + this.id + "' ") 
  172.   doc.write("src='" + this.iconSrc+"' border=0></a>") 
  173.   doc.write("</td><td valign=middle nowrap>") 
  174.   if (USETEXTLINKS) 
  175.   { 
  176.     this.outputLink() 
  177.     doc.write(this.desc + "</a>") 
  178.   } 
  179.   else 
  180.     doc.write(this.desc) 
  181.   doc.write("</td>")  
  182.   doc.write("</table>") 
  183.    
  184.   if (browserVersion == 2) { 
  185.     doc.write("</layer>") 
  186.   } 
  187.  
  188.   if (browserVersion == 1) { 
  189.     this.navObj = doc.all["folder"+this.id] 
  190.     this.iconImg = doc.all["folderIcon"+this.id] 
  191.     this.nodeImg = doc.all["nodeIcon"+this.id] 
  192.   } else if (browserVersion == 2) { 
  193.     this.navObj = doc.layers["folder"+this.id] 
  194.     this.iconImg = this.navObj.document.images["folderIcon"+this.id] 
  195.     this.nodeImg = this.navObj.document.images["nodeIcon"+this.id] 
  196.     doc.yPos=doc.yPos+this.navObj.clip.height 
  197.   } 
  198.  
  199. function outputFolderLink() 
  200.   if (this.hreference) 
  201.   { 
  202.     doc.write("<a href='" + this.hreference + "' TARGET='leaf' ") 
  203.     if (browserVersion > 0) 
  204.       doc.write("onClick='javascript:clickOnFolder("+this.id+")'") 
  205.     doc.write(">") 
  206.   } 
  207.   else 
  208.     doc.write("<a>") 
  209. //  doc.write("<a href='javascript:clickOnFolder("+this.id+")'>")   
  210.  
  211. function addChild(childNode) 
  212.   this.children[this.nChildren] = childNode 
  213.   this.nChildren++ 
  214.   return childNode 
  215.  
  216. function folderSubEntries() 
  217.   var i = 0 
  218.   var se = this.nChildren 
  219.  
  220.   for (i=0; i < this.nChildren; i++){ 
  221.     if (this.children[i].children) //is a folder 
  222.       se = se + this.children[i].subEntries() 
  223.   } 
  224.  
  225.   return se 
  226.  
  227.  
  228. // Definition of class Item (a document or link inside a Folder) 
  229. // ************************************************************* 
  230.  
  231. function Item(itemDescription, itemLink) // Constructor 
  232.   // constant data 
  233.   this.desc = itemDescription 
  234.   this.link = itemLink 
  235.   this.id = -1 //initialized in initalize() 
  236.   this.navObj = 0 //initialized in render() 
  237.   this.iconImg = 0 //initialized in render() 
  238.   this.iconSrc = "ftv2doc.gif" 
  239.  
  240.   // methods 
  241.   this.initialize = initializeItem 
  242.   this.createIndex = createEntryIndex 
  243.   this.hide = hideItem 
  244.   this.display = display 
  245.   this.renderOb = drawItem 
  246.   this.totalHeight = totalHeight 
  247.  
  248. function hideItem() 
  249.   if (browserVersion == 1) { 
  250.     if (this.navObj.style.display == "none") 
  251.       return 
  252.     this.navObj.style.display = "none" 
  253.   } else { 
  254.     if (this.navObj.visibility == "hiden") 
  255.       return 
  256.     this.navObj.visibility = "hiden" 
  257.   }     
  258.  
  259. function initializeItem(level, lastNode, leftSide) 
  260. {  
  261.   this.createIndex() 
  262.  
  263.   if (level>0) 
  264.     if (lastNode) //the last 'brother' in the children array 
  265.     { 
  266.       this.renderOb(leftSide + "<img src='ftv2lastnode.gif' width=16 height=22>") 
  267.       leftSide = leftSide + "<img src='ftv2blank.gif' width=16 height=22>"  
  268.     } 
  269.     else 
  270.     { 
  271.       this.renderOb(leftSide + "<img src='ftv2node.gif' width=16 height=22>") 
  272.       leftSide = leftSide + "<img src='ftv2vertline.gif' width=16 height=22>" 
  273.     } 
  274.   else 
  275.     this.renderOb("")   
  276.  
  277. function drawItem(leftSide) 
  278.   if (browserVersion == 2) 
  279.     doc.write("<layer id='item" + this.id + "' top=" + doc.yPos + " visibility=hiden>") 
  280.      
  281.   doc.write("<table ") 
  282.   if (browserVersion == 1) 
  283.     doc.write(" id='item" + this.id + "' style='position:block;' ") 
  284.   doc.write(" border=0 cellspacing=0 cellpadding=0>") 
  285.   doc.write("<tr><td>") 
  286.   doc.write(leftSide) 
  287.   doc.write("<a href=" + this.link + ">") 
  288.   doc.write("<img id='itemIcon"+this.id+"' ") 
  289.   doc.write("src='"+this.iconSrc+"' border=0>") 
  290.   doc.write("</a>") 
  291.   doc.write("</td><td valign=middle nowrap>") 
  292.   if (USETEXTLINKS) 
  293.     doc.write("<a href=" + this.link + ">" + this.desc + "</a>") 
  294.   else 
  295.     doc.write(this.desc) 
  296.   doc.write("</table>") 
  297.    
  298.   if (browserVersion == 2) 
  299.     doc.write("</layer>") 
  300.  
  301.   if (browserVersion == 1) { 
  302.     this.navObj = doc.all["item"+this.id] 
  303.     this.iconImg = doc.all["itemIcon"+this.id] 
  304.   } else if (browserVersion == 2) { 
  305.     this.navObj = doc.layers["item"+this.id] 
  306.     this.iconImg = this.navObj.document.images["itemIcon"+this.id] 
  307.     doc.yPos=doc.yPos+this.navObj.clip.height 
  308.   } 
  309.  
  310.  
  311. // Methods common to both objects (pseudo-inheritance) 
  312. // ******************************************************** 
  313.  
  314. function display() 
  315.   if (browserVersion == 1) 
  316.     this.navObj.style.display = "block" 
  317.   else 
  318.     this.navObj.visibility = "show" 
  319.  
  320. function createEntryIndex() 
  321.   this.id = nEntries 
  322.   indexOfEntries[nEntries] = this 
  323.   nEntries++ 
  324.  
  325. // total height of subEntries open 
  326. function totalHeight() //used with browserVersion == 2 
  327.   var h = this.navObj.clip.height 
  328.   var i = 0 
  329.    
  330.   if (this.isOpen) //is a folder and _is_ open 
  331.     for (i=0 ; i < this.nChildren; i++)  
  332.       h = h + this.children[i].totalHeight() 
  333.  
  334.   return h 
  335.  
  336.  
  337. // Events 
  338. // ********************************************************* 
  339.  
  340. function clickOnFolder(folderId) 
  341.   var clicked = indexOfEntries[folderId] 
  342.  
  343.   if (!clicked.isOpen) 
  344.     clickOnNode(folderId) 
  345.  
  346.   return  
  347.  
  348.   if (clicked.isSelected) 
  349.     return 
  350.  
  351. function clickOnNode(folderId) 
  352.   var clickedFolder = 0 
  353.   var state = 0 
  354.  
  355.   clickedFolder = indexOfEntries[folderId] 
  356.   state = clickedFolder.isOpen 
  357.  
  358.   clickedFolder.setState(!state) //open<->close  
  359.  
  360. function InitializeSystem() 
  361.   if (doc.all) 
  362.     browserVersion = 1 //IE4   
  363.   else 
  364.     if (doc.layers) 
  365.       browserVersion = 2 //NS4 
  366.     else 
  367.       browserVersion = 0 //other 
  368.  
  369.   SystemRoot.initialize(0, 1, "") 
  370.   SystemRoot.display()
  371.   
  372.   if (browserVersion > 0) 
  373.   { 
  374.     doc.write("<layer top="+indexOfEntries[nEntries-1].navObj.top+"> </layer>") 
  375.  
  376.     // close the whole tree 
  377.     clickOnNode(0) 
  378.     // open the root folder 
  379.     clickOnNode(0) 
  380.   } 
  381.  
  382. // Auxiliary Functions for Folder-Treee backward compatibility 
  383. // ********************************************************* 
  384.  
  385. function gFld(description, hreference) 
  386.   description="<font style=font-size:9pt; font-color: #00ff00;background-color:#ccff99>" + description
  387.   folder = new Folder(description, hreference) 
  388.   return folder 
  389.  
  390. function gLnk(target, description, linkData) 
  391.   description="<font style=font-size:9pt; font-color: #0000ff;background-color:#ccff99>" + description
  392.   fullLink = "" 
  393.  
  394.   if (target==0) 
  395.   { 
  396.     fullLink = "'"+linkData+"' target='leaf'" 
  397.   } 
  398.   else 
  399.   { 
  400.     if (target==1) 
  401.        fullLink = "'http://"+linkData+"' target=_top" 
  402.     else 
  403.        fullLink = "'http://"+linkData+"' target=\"basefrm\""
  404.   } 
  405.  
  406.   linkItem = new Item(description, fullLink)   
  407.   return linkItem 
  408.  
  409. function insFld(parentFolder, childFolder) 
  410.   return parentFolder.addChild(childFolder) 
  411.  
  412. function insDoc(parentFolder, document) 
  413.   parentFolder.addChild(document) 
  414.  
  415. // Global variables 
  416. // **************** 
  417.  
  418. USETEXTLINKS = 1 
  419. indexOfEntries = new Array 
  420. nEntries = 0 
  421. doc = document 
  422. browserVersion = 0 
  423. selectedFolder=0
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.